<!DOCTYPE html>
<!-- saved from url=(0037)http://127.0.0.1/wx/ybss/zhuce/zc.jsp -->
<html class="pixel-ratio-1"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  
  <title>绑定企业</title>

  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no, email=no">
  <!--[if IE]>
  <script src="http://127.0.0.1:80/wx/ybss/js/html5shiv.min.js"></script>
  <![endif]-->
  <script src="resource/md5.js"></script>
  <script src="resource/jquery214.js"></script>
  <script src="resource/fastclick.js"></script>
  <script src="resource/jqueryweui.js"></script>
  <script src="resource/zeptomin.js">
  </script><script src="resource/picker.js"></script>
  <script src="../script/api.js"></script>
   <script type="text/javascript" src="../script/aes.js"></script>
  <script type="text/javascript" charset="UTF-8" src="../script/naes.js"></script>
  <script type="text/javascript" src="../script/modeecb.js"></script>
  <script src="../script/tmd5.js"></script>
  <script type="text/javascript" src="../script/constants.js"></script>


  <style>
   body {
    overflow-x:hidden;
    margin: 0;
   }
   html {
    overflow-x:hidden;
   }
   input:focus {
    outline:none;
}
  </style>

</head>
<body style="background:url(../image/bj.png) repeat-x 0;background-size:100%;">
<div style="height:550px;background:url(../image/mainbg.png) no-repeat right 0 bottom 0%;">
<div>
      <header id="statusBar">
        <img id="banner1" src="../image/top.png" style="width: 100%;position:relative;">
       </header>
 
		<div style="width:100%;display:table;background: #fff;height:51px;line-height: 51px;" >
		<div style="" tapmode="presshover" onclick="api.closeWin();">
		<div style="float:left;display: flex;align-items: center;justify-content: center;height:51px;width:8%;">
			<div style="width:60%;">
			 <img style="display:block;width:100%;height:100%;" src="../image/blc_back.png" />
			</div>
			</div>
			<div style="float:left;height:51px;line-height: 51px;">返回
			</div>
			</div>
			 
		<div id="title" style="height:51px;line-height: 51px;text-align:center;width:60%;float:left">
		
		</div>	
		<div tapmode="presshover" onclick="addtaxcode();">
			<div style="float:right;text-align: left;margin-right:20px;color: #43CD80">
			 完成
			</div>
			</div>
		</div>
          <div style="height:20px"></div>
          <div>
           <input id="taxcode" style="float:left;width:80%;height:30px;padding:5px;font-size: 16px;border:0px;" placeholder="请输入税号或扫描二维码"/>
          <div style="float:right;width:17.2%;height:40px;line-height:40px;background: #fff;text-align: center;" tapmode="presshover" onclick="scanQr();">
           <img src="../image/tabBar/sm.png" style="width:30px;margin-top:5px"/>
          </div>
          </div>
          <input name="sm" id="sm" type="hidden"/>
</div>
<script>


function sdsr(){
$("#hide").show();
$("#type").val("1");
$("#taxcode").val("");
}
 function scanQr(){
  var FNScanner = api.require('FNScanner');
		FNScanner.openScanner({
		    autorotation: true
		}, function(ret, err) {
		  setTimeout(function(){
		   console.log(JSON.stringify(ret));
		   if(ret.eventType == "success"){
				var content = JSON.stringify(ret.content);
	    
			    var userid_val = content.split('&')[4];	
              
			     if(typeof(userid_val) == "undefined" || userid_val=="undefined"){
   		            alert("二维码异常");
   		            return;
   		         }
			      $("#sm").val(userid_val);
			      if(userid_val!=undefined){
			      $("#taxcode").val("扫描成功");
			      $("#taxcode").attr("readOnly","true");
			      }
			}
		 },500); 	
		});
  
  }

	function addtaxcode(){
  
    var taxcode = document.getElementById("taxcode").value;
	var phone = $api.getStorage("dl_phone");
	var sm = document.getElementById("sm").value;
	var type = "2";
	if(taxcode!='暂无（选填）'&&taxcode!="扫描成功"&&taxcode!=""){
	    sm = taxcode ;
	    type = "1";
	 }

    var a = check0();

if(a){
    $("#wzc").hide();
    $("#yzc").show();
    
    var callback = function(ret, err){
            if (ret.success == "true") {
				api.sendEvent({
	                name:'reloadUinfo'
                });
                api.alert({msg:'保存成功'});
                api.closeWin();
                
       		 }else{
       		    api.alert({msg:'保存失败,请检查云平台是否设置企业基本信息'});
       		 	$("#taxcode").val("");
             }
        }
    var parameter = {"openid":phone,"phone":phone,"sm":sm,"type":type,"deviceName":api.deviceName};
    apiAjax(JSON.stringify(parameter),url.tjsh,callback);
}
    
  }
  
	
	apiready = function(){
	    api.parseTapmode();
	    if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
		}
	    $api.fixStatusBar( $api.dom('header') );
		code = api.pageParam.code;
		if(code == ""){
		   $("#title").text("绑定企业");
		}else{
		   $("#title").text("更换企业");
		}
	}
	
	 
	 
	function check0(){
	   var taxcode = document.getElementById("taxcode").value;
	   var phone = $api.getStorage("dl_phone");
	   var sm = document.getElementById("sm").value;
	   if(taxcode!='暂无'&&taxcode!="已扫描"){
	    document.getElementById("sm").value = taxcode ;
	    var sm = document.getElementById("sm").value;
	   }
	   var sm = document.getElementById("sm").value;
	   if(sm==null||sm==undefined||sm==""){
	    alert("税号不能为空");
	    return false;
	   }

	   return true;
	}
	 
	 
  
	
</script>
	

</body></html>